#pragma once

#include <bcm2835.h>
#include <iostream>
#include <stdexcept>
#include "comm/singleton.hpp"

/// @brief 封装bcm2835 控制树莓派GPIO
class Gpio{
public:
    Gpio();
    //程序退出时才会调用 用Singleton封装后
    ~Gpio();
public:

    /// @brief 设置GPIO设置模式
    void SetGpioMode(uint8_t pin,uint8_t model);

    void WriteGpio(uint8_t pin, bool value);
    bool ReadGpio(uint8_t pin);

    /// @brief 
    /// @param address 
    void SetI2cAddress(uint8_t address);

    void I2cWrite(std::string& data);

    void I2cRead(std::string* data);

    void SpiWrite(std::string& data);

    void SpiRead(std::string* data);
private:
};